#include <iostream>
#include <string>
#include <vector>

class SplitHelper
{
public:
    static int Split(const std::string& str, const std::string& sep, std::vector<std::string>& result)
    {
        int pos = 0, idx = 0;
        while(idx < str.size())
        {
            pos = str.find(sep, idx);
            // std::cout << "pos: " << pos <<" idx: " << idx<< std::endl;
            if(pos == std::string::npos)
            {
                result.push_back(str.substr(idx));
                break;
            }
            if(pos == idx) //idx这个位置就是sep
            {
                idx += sep.size();
                continue;
            }
            result.push_back(str.substr(idx, pos - idx));
            // std::cout << str.substr(idx, pos - idx) << std::endl;
            // idx = pos + sizeof sep;     //
            idx = pos + sep.size();
            // std::cout << "newidx" << idx << std::endl;
        }
        return result.size();
    }
};

int main()
{
    std::string str = "...nnn...11.44...&(&)..";
    std::vector<std::string> result;
    SplitHelper::Split(str, ".", result);
    for(auto& s : result)
        std::cout << s << std::endl;
    return 0;
}